-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add ThreadContextStack injection capability #3810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Conversation
- Add ThreadContextStackFactory following ThreadContextMapFactory pattern - Extend Provider class with ThreadContextStack support (backward compatible) - Add NOOP_STACK constant to ThreadContext - Support log4j2.threadContextStack system property - Add comprehensive tests - Update package version for BND compliance Fixes apache#1507
@yybmion, do you have a use case? Do you need this functionality for a certain system of yours that is deployed to production? Would you mind giving us some more context, please? |
Hi @vy, Thank you for the question! You previously provided positive feedback on this issue, stating:
I understand your concern about whether this is truly essential functionality. You're absolutely right that many use cases can be implemented using custom That said, I approached this change from two angles: 1. Architectural ConsistencyAs you previously noted, 2. Purpose-Driven Use CasesWhile
So while this feature may not be strictly required in the minimal sense, I think it adds clarity and purpose-driven extensibility that complements the existing I believe this aligns with the design vision you described, and I'd be happy to discuss this further if you have additional concerns. Best regards |
Implements custom
ThreadContextStack
injection capability as requested in #1507.Users can now inject custom
ThreadContextStack
implementations just likeThreadContextMap
.Changes
NOOP_STACK
constant and updated initialization logiclog4j2.threadContextStack=com.example.MyCustomStack
log4j2.component.properties
Checklist
✅ Required checks
License: I confirm that my changes are submitted under the Apache License, Version 2.0.
Commit signatures: All commits are signed and verifiable. (See GitHub Docs on Commit Signature Verification).
Code formatting: The code is formatted according to the project’s style guide.
How to check and fix formatting
./mvnw spotless:check
./mvnw spotless:apply
See the build instructions for details.
Build & Test: I verified that the project builds and all unit tests pass.
How to build the project
Run:
./mvnw verify
See the build instructions for details.
🧪 Tests (select one)
📝 Changelog (select one)
src/changelog/.2.x.x
. (See Changelog Entry File Guide).fixes #1507